<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增旅游资讯信息')" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-info-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">旅游资讯标题：</label>
                <div class="col-sm-8">
                    <input name="title" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">资讯首页大图：</label>
                <div class="col-sm-8">
                    <input id="infoPic" name="infoPic"  onclick="uploadTupian()" type="text"  readonly="true" >
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">旅游资讯内容：</label>
                <div class="col-sm-8">
                    <input id="content" name="content"  type="hidden">
                    <div id="editor" class="summernote"></div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: summernote-js" />
    <script type="text/javascript">
        var prefix = ctx + "lvyou/info"
        $("#form-info-add").validate({
            focusCleanup: true
        });

        $(document).ready(function () {
            $('.summernote').summernote({
                lang: 'zh-CN'
            });
        });

        function uploadTupian() {
            var options = {
                title: '旅游资讯图片上传',
                width: "800",
                height:$(window).height() - 50,
                url: ctx+"lvyou/spot" + "/uploadTupian",
                callBack: doSubmit2
            };
            $.modal.openOptions(options);
        }

        function doSubmit2(index, layero){
            var body = layer.getChildFrame('body', index);
            $("#infoPic").val(body.find('#spotPic').val());  //搜索名称
            layer.close(index);
            /*if (body.find('#filePath')[0].files[0] == null) {
                $.modal.alertWarning("请先选择文件路径");
                return false;
            }
            formData.append('fileName', body.find("input[name='fileName']").val());
            formData.append('file', body.find('#filePath')[0].files[0]);
            $.ajax({
                url: prefix + "/add",
                type: 'post',
                cache: false,
                data: formData,
                processData: false,
                contentType: false,
                dataType: "json",
                success: function(result) {
                    layer.close(index);
                    $.operate.successCallback(result);
                }
            });*/

        }

        function submitHandler() {
            if ($.validate.form()) {
                var html=$('#editor').summernote('code');
                $("#content").val(html);
                $.operate.save(prefix + "/add", $('#form-info-add').serialize());
            }
        }
    </script>
</body>
</html>